package com.nbcio.iot.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * MQTT 配置属性
 */

@Data
@Component
@ConfigurationProperties(prefix = "iot.mqtt")
public class IotMqttProperties {
    private String brokerUrl;
    private String clientId = "nbmade-iot";
    private String username;
    private String password;
    private boolean cleanSession = true;
    private int keepAlive = 30;
    private boolean reconnect = true;
    private String defaultTopicPattern = "devices/+/up";

    // 内嵌 Broker 配置
    private Embedded embedded = new Embedded();

    @Data
    public static class Embedded {
        private boolean enabled = false;
        private String host = "0.0.0.0";
        private int port = 1883;
        private boolean allowAnonymous = true;
        private String persistenceDir = "data/mqtt";
        private String username;
        private String password;
    }
}
